package com.braveman.im.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.braveman.im.R;
import com.braveman.im.bean.CardDetailsBean;
import com.braveman.im.manager.ApiManager;
import com.braveman.im.ui.weiget.ButtonItem;
import com.ht.baselibs.retrofit.NetCallBack;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;

import retrofit2.Call;
import retrofit2.Response;

/**
 * 作者 昊昊.
 * 年份 2017/11/9.
 * 时间 16:36.
 * 项目名称 hhkj.
 */

/**
 * 名片管理对方名片详情
 */
public class OtherDetailsActivity extends BaseActivity {
    private String cardId;
    private ButtonItem activityOtherDetailsName;
    private ButtonItem activityOtherDetailsSex;
    private ButtonItem activityOtherDetailsPhone;
    private ButtonItem activityOtherDetailsPlace;
    private ButtonItem activityOtherDetailsCity;
    private TextView activityOtherDetailsSignature;
    private ButtonItem activityOtherDetailsCompanyName;
    private ButtonItem activityOtherDetailsDuty;
    private ButtonItem activityOtherDetailsCompyPhone;
    private ButtonItem activityOtherDetailsAddress;
    private ButtonItem activityOtherDetailsZipCode;
    private CardDetailsBean cardDetailsBean;

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("详细资料").setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.finishActivity(OtherDetailsActivity.this);
            }
        });
    }

    @Override
    protected int initContentView() {
        return R.layout.activity_other_details;
    }

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected void initChildView() {
        activityOtherDetailsName = (ButtonItem) findViewById(R.id.activity_other_details_name);
        activityOtherDetailsSex = (ButtonItem) findViewById(R.id.activity_other_details_sex);
        activityOtherDetailsPhone = (ButtonItem) findViewById(R.id.activity_other_details_phone);
        activityOtherDetailsPlace = (ButtonItem) findViewById(R.id.activity_other_details_place);
        activityOtherDetailsCity = (ButtonItem) findViewById(R.id.activity_other_details_city);
        activityOtherDetailsSignature = (TextView) findViewById(R.id.activity_other_details_signature);
        activityOtherDetailsCompanyName = (ButtonItem) findViewById(R.id.activity_other_details_company_name);
        activityOtherDetailsDuty = (ButtonItem) findViewById(R.id.activity_other_details_duty);
        activityOtherDetailsCompyPhone = (ButtonItem) findViewById(R.id.activity_other_details_compy_phone);
        activityOtherDetailsAddress = (ButtonItem) findViewById(R.id.activity_other_details_address);
        activityOtherDetailsZipCode = (ButtonItem) findViewById(R.id.activity_other_details_zip_code);


    }

    @Override
    protected void initIntentData(Intent callIntent) {
        cardId = callIntent.getStringExtra("cardId");
    }

    @Override
    protected void initChildData() {
        cardDetailsBean = new CardDetailsBean();
        ApiManager.getApi().getDetails(cardId).enqueue(new NetCallBack<CardDetailsBean>() {
            @Override
            protected void onSuccess(Call<CardDetailsBean> call, Response<CardDetailsBean> response) {
                cardDetailsBean = response.body();
                if (response != null) {
                    activityOtherDetailsName.tv_des.setText(cardDetailsBean.name);
                    if (cardDetailsBean.gender.equals("1")) {
                        activityOtherDetailsSex.tv_des.setText("男");
                    } else {
                        activityOtherDetailsSex.tv_des.setText("女");
                    }
                    activityOtherDetailsPhone.tv_des.setText(cardDetailsBean.personalPhone);
                    activityOtherDetailsPlace.tv_des.setText(cardDetailsBean.hometownName);
                    activityOtherDetailsCity.tv_des.setText(cardDetailsBean.residenceName);
                    activityOtherDetailsSignature.setText(cardDetailsBean.information);
                    activityOtherDetailsCompanyName.tv_des.setText(cardDetailsBean.corpName);
                    activityOtherDetailsDuty.tv_des.setText(cardDetailsBean.position);
                    activityOtherDetailsCompyPhone.tv_des.setText(cardDetailsBean.businessPhone);
                    activityOtherDetailsAddress.tv_des.setText(cardDetailsBean.corpAddressName);
                    activityOtherDetailsZipCode.tv_des.setText(cardDetailsBean.zipCode);
                }
            }
        });
    }

    @Override
    protected void setChildViewListener() {

    }
}
